#include "EchoWebsock.h"
#include "Common.h"
using namespace std;
extern vector<WebSocketConnectionPtr>* wsList;
void EchoWebsock::handleNewMessage(const WebSocketConnectionPtr& wsConnPtr, std::string &&message, const WebSocketMessageType &type)
{


    //write your application logic here
   // wsConnPtr->send(message);

    for (int i = 0; i < NsCommon::wsList->size(); ++i) {
        NsCommon::wsList->at(i)->send("server rec msg is :"+message);
        NsCommon::a=10;
        cout<<NsCommon::a<<endl;
    }
}
void EchoWebsock::handleNewConnection(const HttpRequestPtr &req,const WebSocketConnectionPtr& wsConnPtr)
{
    //write your application logic here
    NsCommon::wsList->push_back(wsConnPtr);

    cout<<"size: "<<NsCommon::wsList->size()<<endl;
}
void EchoWebsock::handleConnectionClosed(const WebSocketConnectionPtr& wsConnPtr)
{
    //write your application logic here
}
